<?php
$id = $_GET['id'];
$shopcode = 'shop' . $id;
if (isset(Yii::app()->request->cookies[$shopcode]->value)) {
    $shoparry = Yii::app()->request->cookies[$shopcode]->value;
    $savedCardArray = json_decode($shoparry, true);
}
//if(isset($sql)){
//echo $sql;
//}
?>
<div class="noidung">
    <?php $urlbtnxem = 'http://www.salesmartlink.com/icon/btnxem.PNG'; ?>
    <div style="padding-left: 0px; width: 100%">
        <div class="colleft">
            <?php $this->renderPartial('commercial'); ?>
        </div>
        <div class="colright" style="margin: 0px">
            <div style="margin-left: 7px; width: 100%">
                <?php
                $css = "bgtopic340";
                $dem = null;
                if (!empty($category)) {
                    $dem = $category->title;

                    if (strlen($dem) >= 60) {
                        $css = "bgtopic600";
                    } else if (strlen($dem) >= 39) {
                        $css = "bgtopic500";
                    }
                }
                //  echo $sql;
                ?>


                <div class="<?php echo $css; ?>">
                    <div class="topic_title">
                        <?php
                        if (!empty($category)) {
                            echo $category->title;
                        } else if (!empty($result)) {
                            echo $result;
                        }
                        ?>
                    </div>
                </div>


                <?php
                if (!empty($produc)) {
                    foreach ($produc as $pr) {
                        ?>
                        <div class="boxsp">
                            <div class="sale">
                                <div class="txtdiscount">
                                    <?php
                                    if ($pr->discount > 1000) {
                                        echo '<div style="padding-top: 5px;font-size: 16px;">Quà</div>';
                                    } elseif ($pr->discount > 999) {
                                        echo '<div style="padding-top: 5px;font-size: 16px;">Mới</div>';
                                    } else {
                                        echo $pr->discount . '<span>%</span>';
                                       
                                        }
 ?>

                                    </div>
                                </div>
                                <div class="boxspImg">
                                    <?php
                                    $getUrl = $pr->pr_url;
                                    $tang = "_top";
                                    if ($getUrl === "") {
                                        $getUrl = $this->createUrl('/shop/' . $savedCardArray[2] . '/noi-dung') . '/' . $pr->prid . '/' . $pr->asia_name . '/#here';
                                    } else {
                                        $tang = "_blank";
                                    }
                                    ?>
                                    <a href="<?php echo $getUrl; ?>" title="<?php echo $pr->pr_name; ?>" target="<?php echo $tang; ?>">
                                        <img src="<?php echo Yii::app()->request->baseUrl . '/uploadshop/product/' . $pr->avatar ?>" width="190" height="205">
                                    </a>
                                </div>
                                <div class="boxspTitle">
                                    <a href="<?php echo $getUrl; ?>" title="<?php echo $pr->pr_name; ?>" target="<?php echo $tang; ?>">
                                        <?php echo $pr->pr_name; ?>
                                    </a>
                                </div>
                                <div class="boxspPrice">
                                    <div class="txttimer">
                                        <div class="product-date-<?php echo $pr->prid; ?>"></div>

                                        <script>
                                            jQuery(document).ready(function() {

                                                jQuery(".product-date-<?php echo $pr->prid; ?>").countdown({
            <?php
            if (($pr->pr_enddate) == '') {
                $date = "1/1/2013 0:0:0";
            } else {
                $date = $pr->pr_enddate;
            }
            ?>

                                                    date: "<?php echo $date; ?>",
                                                    render: function(data) {
                                                        jQuery(this.el).html("Còn " + this.leadingZeros(data.days, 2) + " <span> ngày </span>");
                                                    }
                                                });

                                            });

                                        </script>
                                    </div>
                                    <div class="btnXem">

                                        <a href="<?php echo $getUrl; ?>" title="<?php echo $pr->pr_name; ?> " target="<?php echo $tang; ?>"><img src="<?php echo $urlbtnxem; ?>"></a>
                                    </div>
                                </div>
                            </div>
                            <?php
                        }
                    }
                    ?>
                    <div class="clear"></div>

                    <div id="pagination"  style="margin-top: 10px">
                        <?php
                        /*
                          $this->widget('CLinkPager', array(
                          'pages' => $pages,
                          'htmlOptions' => array('class' => 'pager'),
                          'header' => ''
                          ));
                         */
                        $this->widget('CLinkPager', array('pages' => $pages, 'header' => '', 'nextPageLabel' => 'Next', 'prevPageLabel' => 'Prev', 'selectedPageCssClass' => 'active', 'hiddenPageCssClass' => 'disabled', 'htmlOptions' => array('class' => 'pagination', )))
                        ?>
                </div>



            </div>
        </div>
    </div>

    <div style="clear: both; padding-bottom: 10px"></div>
</div>


